FROM centos:6.7
MAINTAINER xuegangliu "1453860636@qq.com"  

# 使用yum的方式安装mysql；
RUN yum install -y mysql-server mysql  

# 安装完成以后，执行以下命令。配置用户名密码相关信息；
RUN /etc/init.d/mysqld start &&\  
    mysql -e "grant all privileges on *.* to 'root'@'%' identified by 'lxgmysql' WITH GRANT OPTION ;"&&\  
    mysql -e "grant all privileges on *.* to 'root'@'localhost' identified by 'lxgmysql' WITH GRANT OPTION ;"&&\ 
    mysql -u root -plxgmysql -e "show databases;"  

# 镜像暴露3306端口；
EXPOSE 3306

# 容器启动后执行以下命令，启动mysql；
CMD ["/usr/bin/mysqld_safe"]
